set more off
log using "\\file\UsersW$\wrr15\Home\My Documents\My Files\ATANDA AKINWANDE\BCD PAPER\HEALTH ECONOMICS revision\NEW DATA AND PROGRAMS (20171021)\TABLE4.smcl", replace
use "\\file\UsersW$\wrr15\Home\My Documents\My Files\ATANDA AKINWANDE\BCD PAPER\HEALTH ECONOMICS revision\NEW DATA AND PROGRAMS (20171021)\BCD_dataset_09_11_2017", clear

//ge phpnh = 100*phn

//ge lhl = 100*lhsl

summ phpnh lhl prod pop14 pop65 male lex infmo tobaco alcohc gdpg
replace lhl = log(lhl)

sort country year
xtset cid year

tabulate cid, gen(cid)

forvalues i = 1/27 {
                gen cidyear`i' = cid`i'*year
}

////////////////////////////////////////////////////////////
///////////////////  LHL - Model (7) ///////////////////////
////////////////////////////////////////////////////////////

/////// First test for serial correlation
xtserial lhl lprod k pop14 pop65 male llex linfmo cid1-cid27 year cidyear1-cidyear27

/////// Next test for cross-sectional correlation
/////// I use the Pesaran test because it can be used with unbalanced data
xtreg lhl lprod k pop14 pop65 male llex linfmo cid1-cid27 year cidyear1-cidyear27, fe
xtcsd, pesaran

/////// Next I estimate the model using PCSE
xtpcse lhl lprod k pop14 pop65 male llex linfmo cid1-cid27 year cidyear1-cidyear27, correlation(ar1)
// I couldn't estimate the PCSE model because I obtained the following error message:
//no time periods are common to all panels, cannot estimate disturbance
//covariance matrix using casewise inclusion

/////// Finally, I used the different heterogeneous panel models
xtmg lhl lprod k pop14 pop65 male llex linfmo, trend 
xtmg lhl lprod k pop14 pop65 male llex linfmo, cce trend 
xtmg lhl lprod k pop14 pop65 male llex linfmo, aug trend 


////////////////////////////////////////////////////////////
///////////////////  LHL - Model (8) ///////////////////////
////////////////////////////////////////////////////////////

/////// First test for serial correlation
xtserial lhl lprod k pop14 pop65 male llex linfmo ltobaco lalcohc cid1-cid27 year cidyear1-cidyear27

/////// Next test for cross-sectional correlation
/////// I use the Pesaran test because it can be used with unbalanced data
xtreg lhl lprod k pop14 pop65 male llex linfmo ltobaco lalcohc cid1-cid27 year cidyear1-cidyear27, fe
//xtcsd, pesaran
// I couldn't run the Pesaran test. I received the following error message:
//Error: The panel is highly unbalanced.
//Not enough common observations across panel to perform Pesaran's test.
//insufficient observations

/////// Next I estimate the model using PCSE
xtpcse lhl lprod k pop14 pop65 male llex linfmo ltobaco lalcohc cid1-cid27 year cidyear1-cidyear27, correlation(ar1)

/////// Finally, I used the different heterogeneous panel models
xtmg lhl lprod k pop14 pop65 male llex linfmo ltobaco lalcohc, trend 
xtmg lhl lprod k pop14 pop65 male llex linfmo ltobaco lalcohc, cce trend 
xtmg lhl lprod k pop14 pop65 male llex linfmo ltobaco lalcohc, aug trend 



////////////////////////////////////////////////////////////
///////////////////  LHL - Model (9) ///////////////////////
////////////////////////////////////////////////////////////

/////// First test for serial correlation
xtserial lhl lprod k pop14 pop65 male llex linfmo ltobaco lalcohc gdpg cid1-cid27 year cidyear1-cidyear27

/////// Next test for cross-sectional correlation
/////// I use the Pesaran test because it can be used with unbalanced data
xtreg lhl lprod k pop14 pop65 male llex linfmo ltobaco lalcohc gdpg cid1-cid27 year cidyear1-cidyear27, fe
//xtcsd, pesaran
// I couldn't run the Pesaran test. I received the following error message:
//Error: The panel is highly unbalanced.
//Not enough common observations across panel to perform Pesaran's test.
//insufficient observations

/////// Next I estimate the model using PCSE
xtpcse lhl lprod k pop14 pop65 male llex linfmo ltobaco lalcohc gdpg cid1-cid27 year cidyear1-cidyear27, correlation(ar1)

/////// Finally, I used the different heterogeneous panel models
xtmg lhl lprod k pop14 pop65 male llex linfmo ltobaco lalcohc gdpg, trend 
xtmg lhl lprod k pop14 pop65 male llex linfmo ltobaco lalcohc gdpg, cce trend 
xtmg lhl lprod k pop14 pop65 male llex linfmo ltobaco lalcohc gdpg, aug trend 


////////////////////////////////////////////////////////////
///////////////////  PHPNH - Model (7) ///////////////////////
////////////////////////////////////////////////////////////

/////// First test for serial correlation
xtserial phpnh prod pop14 pop65 male lex infmo cid1-cid27 year cidyear1-cidyear27

/////// Next test for cross-sectional correlation
/////// I use the Pesaran test because it can be used with unbalanced data
xtreg phpnh prod pop14 pop65 male lex infmo cid1-cid27 year cidyear1-cidyear27, fe
xtcsd, pesaran

/////// Next I estimate the model using PCSE
xtpcse phpnh prod pop14 pop65 male lex infmo cid1-cid27 year cidyear1-cidyear27, correlation(ar1)



/////// Finally, I used the different heterogeneous panel models
xtmg phpnh prod pop14 pop65 male lex infmo, trend 
xtmg phpnh prod pop14 pop65 male lex infmo, cce trend 
xtmg phpnh prod pop14 pop65 male lex infmo, aug trend 


////////////////////////////////////////////////////////////
///////////////////  PHPNH - Model (8) ///////////////////////
////////////////////////////////////////////////////////////

/////// First test for serial correlation
xtserial phpnh prod pop14 pop65 male lex infmo tobaco alcohc cid1-cid27 year cidyear1-cidyear27

/////// Next test for cross-sectional correlation
//xtreg phpnh prod pop14 pop65 male lex infmo tobaco alcohc cid1-cid27 year cidyear1-cidyear27, fe
//xtcsd, pesaran
// I couldn't run the Pesaran test. I received the following error message:
//Error: The panel is highly unbalanced.
//Not enough common observations across panel to perform Pesaran's test.
//insufficient observations

//xtpcse phpnh prod pop14 pop65 male lex infmo tobaco alcohc cid1-cid27 year cidyear1-cidyear27, correlation(ar1)
// I couldn't estimate the PCSE model because I obtained the following error message:
//no time periods are common to all panels, cannot estimate disturbance
//covariance matrix using casewise inclusion


/////// Finally, I used the different heterogeneous panel models
xtmg phpnh prod pop14 pop65 male lex infmo tobaco alcohc, trend 
xtmg phpnh prod pop14 pop65 male lex infmo tobaco alcohc, cce trend 
xtmg phpnh prod pop14 pop65 male lex infmo tobaco alcohc, aug trend 


////////////////////////////////////////////////////////////
///////////////////  PHPNH - Model (9) ///////////////////////
////////////////////////////////////////////////////////////

/////// First test for serial correlation
xtserial phpnh prod pop14 pop65 male lex infmo tobaco alcohc gdpg cid1-cid27 year cidyear1-cidyear27

/////// Next test for cross-sectional correlation
/////// I use the Pesaran test because it can be used with unbalanced data
//xtreg phpnh prod pop14 pop65 male lex infmo tobaco alcohc gdpg cid1-cid27 year cidyear1-cidyear27, fe
//xtcsd, pesaran
// I couldn't run the Pesaran test. I received the following error message:
//Error: The panel is highly unbalanced.
//Not enough common observations across panel to perform Pesaran's test.
//insufficient observations

/////// Next I estimate the model using PCSE
//xtpcse phpnh prod pop14 pop65 male lex infmo tobaco alcohc gdpg cid1-cid27 year cidyear1-cidyear27, correlation(ar1)
// I couldn't estimate the PCSE model because I obtained the following error message:
//no time periods are common to all panels, cannot estimate disturbance
//covariance matrix using casewise inclusion

/////// Finally, I used the different heterogeneous panel models
xtmg phpnh prod pop14 pop65 male lex infmo tobaco alcohc gdpg, trend 
xtmg phpnh prod pop14 pop65 male lex infmo tobaco alcohc gdpg, cce trend 
xtmg phpnh prod pop14 pop65 male lex infmo tobaco alcohc gdpg, aug trend 





////////////////////////////////////////////////////////////
///////////////////  PHPNH + k - Model (7) ///////////////////////
////////////////////////////////////////////////////////////


/////// Next I estimate the model using PCSE
xtpcse phpnh prod k pop14 pop65 male lex infmo cid1-cid27 year cidyear1-cidyear27, correlation(ar1)



/////// Finally, I used the different heterogeneous panel models
xtmg phpnh prod k pop14 pop65 male lex infmo, trend 
xtmg phpnh prod k pop14 pop65 male lex infmo, cce trend 
xtmg phpnh prod k pop14 pop65 male lex infmo, aug trend 


////////////////////////////////////////////////////////////
///////////////////  PHPNH + k - Model (8) ///////////////////////
////////////////////////////////////////////////////////////


//xtpcse phpnh prod pop14 pop65 male lex infmo tobaco alcohc cid1-cid27 year cidyear1-cidyear27, correlation(ar1)
// I couldn't estimate the PCSE model because I obtained the following error message:
//no time periods are common to all panels, cannot estimate disturbance
//covariance matrix using casewise inclusion


/////// Finally, I used the different heterogeneous panel models
xtmg phpnh prod k pop14 pop65 male lex infmo tobaco alcohc, trend 
xtmg phpnh prod k pop14 pop65 male lex infmo tobaco alcohc, cce trend 
xtmg phpnh prod k pop14 pop65 male lex infmo tobaco alcohc, aug trend 


////////////////////////////////////////////////////////////
///////////////////  PHPNH + k - Model (9) ///////////////////////
////////////////////////////////////////////////////////////


/////// Next I estimate the model using PCSE
//xtpcse phpnh prod pop14 pop65 male lex infmo tobaco alcohc gdpg cid1-cid27 year cidyear1-cidyear27, correlation(ar1)
// I couldn't estimate the PCSE model because I obtained the following error message:
//no time periods are common to all panels, cannot estimate disturbance
//covariance matrix using casewise inclusion

/////// Finally, I used the different heterogeneous panel models
xtmg phpnh prod k pop14 pop65 male lex infmo tobaco alcohc gdpg, trend 
xtmg phpnh prod k pop14 pop65 male lex infmo tobaco alcohc gdpg, cce trend 
xtmg phpnh prod k pop14 pop65 male lex infmo tobaco alcohc gdpg, aug trend 

log close
